import { POINT_PAINT } from "./conf";

export const PT_MODES = ["draw_point"];

export function generatePointLayer({ map, mode, features }) {
	features.forEach((feature) => {
		feature.properties = {
			...POINT_PAINT,
			...feature.properties,
		};
	});

	const circleLayer = {
		id: `${mode}-${features[0].id}-circle`,
		type: "circle",
		source: {
			type: "geojson",
			data: {
				type: "FeatureCollection",
				features,
			},
		},
		paint: {
			"circle-color": ["get", "circleColor"],
			"circle-radius": ["get", "circleRadius"],
			"circle-opacity": ["get", "circleOpacity"],
			"circle-stroke-color": ["get", "circleStrokeColor"],
			"circle-stroke-width": ["get", "circleStrokeWidth"],
			"circle-stroke-opacity": ["get", "circleStrokeOpacity"],
		},
	};

	map.addLayer(circleLayer);

	return [circleLayer.id];
}

export function isPointMode(mode) {
	return PT_MODES.includes(mode);
}
